home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / ScrollerEditor.cpp < prev    next >
Text File  |  1997-05-03  |  5KB  |  179 lines

  1. /*
  2.  *  File:       ScrollerEditor.cpp
  3.  *  Summary:       A view that knows how to edit a TScroller.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/07/96    JDJ        Created
  12.  */
  13.  
  14. #include "ScrollerEditor.h"
  15.  
  16. #include <ZColorSwatch.h>
  17. #include <ZControl.h>
  18. #include <ZTextBox.h>
  19.  
  20.  
  21. // ===================================================================================
  22. //    class CEditScrollerCommand
  23. // ===================================================================================
  24.  
  25. //---------------------------------------------------------------
  26. //
  27. // CEditScrollerCommand::~CEditScrollerCommand
  28. //
  29. //---------------------------------------------------------------
  30. CEditScrollerCommand::~CEditScrollerCommand()
  31. {
  32. }
  33.  
  34.  
  35. //---------------------------------------------------------------
  36. //
  37. // CEditScrollerCommand::CEditScrollerCommand
  38. //
  39. //---------------------------------------------------------------
  40. CEditScrollerCommand::CEditScrollerCommand(TScroller* pane, const SScrollerInfo& oldInfo, const SScrollerInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  41. {
  42. }
  43.  
  44.  
  45. //---------------------------------------------------------------
  46. //
  47. // CEditScrollerCommand::UpdatePane
  48. //
  49. //---------------------------------------------------------------
  50. void CEditScrollerCommand::UpdatePane(const SScrollerInfo& info)
  51. {
  52.     mPane->SetInfo(info);
  53. }
  54.  
  55. #pragma mark -
  56.  
  57. // ===================================================================================
  58. //    CScrollerEditor
  59. // ===================================================================================
  60.  
  61. static TReanimatorRegister<CScrollerEditor> sScrollerEditorRegistrar;
  62.  
  63. //---------------------------------------------------------------
  64. //
  65. // CScrollerEditor::~CScrollerEditor
  66. //
  67. //---------------------------------------------------------------
  68. CScrollerEditor::~CScrollerEditor()
  69. {
  70. }
  71.  
  72.  
  73. //---------------------------------------------------------------
  74. //
  75. // CScrollerEditor::CScrollerEditor
  76. //
  77. //---------------------------------------------------------------
  78. CScrollerEditor::CScrollerEditor(TView* superView) : Inherited(superView)
  79. {
  80. }
  81.  
  82.  
  83. //---------------------------------------------------------------
  84. //
  85. // CScrollerEditor::Create                                [static]
  86. //
  87. //---------------------------------------------------------------
  88. MReanimatable* CScrollerEditor::Create(MReanimatable* parent)
  89. {
  90.     return new CScrollerEditor(dynamic_cast<TView*>(parent));
  91. }
  92.  
  93.  
  94. //---------------------------------------------------------------
  95. //
  96. // CScrollerEditor::GetEditorInfo        
  97. //
  98. //---------------------------------------------------------------
  99. SScrollerInfo CScrollerEditor::GetEditorInfo() const
  100. {
  101.     SScrollerInfo info;
  102.     
  103.     TTextBox* textBox = nil;
  104.     TControl* control = nil;
  105.     TColorSwatch* color = nil;
  106.         
  107.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("SubPane Name"));
  108.     info.subPaneName = textBox->GetText();
  109.     
  110.     control = dynamic_cast<TControl*>(this->FindSubPane("Has Horz"));
  111.     info.hasHorzScrollBar = control->GetValue();
  112.     
  113.     control = dynamic_cast<TControl*>(this->FindSubPane("Has Vert"));
  114.     info.hasVertScrollBar = control->GetValue();
  115.     
  116.     color = dynamic_cast<TColorSwatch*>(this->FindSubPane("Back Color"));
  117.     info.backColor = color->GetColor();
  118.     
  119.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Left Indent"));
  120.     info.indent.left = textBox->GetValue();
  121.     
  122.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Right Indent"));
  123.     info.indent.right = textBox->GetValue();
  124.     
  125.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Top Indent"));
  126.     info.indent.top = textBox->GetValue();
  127.     
  128.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Bottom Indent"));
  129.     info.indent.bottom = textBox->GetValue();
  130.     
  131.     control = dynamic_cast<TControl*>(this->FindSubPane("Erase on Update"));
  132.     info.eraseOnUpdate = control->GetValue();
  133.     
  134.     return info;
  135. }
  136.  
  137.  
  138. //---------------------------------------------------------------
  139. //
  140. // CScrollerEditor::SetEditorInfo
  141. //
  142. //---------------------------------------------------------------
  143. void CScrollerEditor::SetEditorInfo(const SScrollerInfo& info)
  144. {
  145.     TTextBox* textBox = nil;
  146.     TControl* control = nil;
  147.     TColorSwatch* color = nil;
  148.     
  149.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("SubPane Name"));
  150.     textBox->SetText(info.subPaneName);
  151.     
  152.     control = dynamic_cast<TControl*>(this->FindSubPane("Has Horz"));
  153.     control->SetValue(info.hasHorzScrollBar);
  154.     
  155.     control = dynamic_cast<TControl*>(this->FindSubPane("Has Vert"));
  156.     control->SetValue(info.hasVertScrollBar);
  157.     
  158.     color = dynamic_cast<TColorSwatch*>(this->FindSubPane("Back Color"));
  159.     color->SetColor(info.backColor);
  160.     
  161.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Left Indent"));
  162.     textBox->SetValue(info.indent.left);
  163.     
  164.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Right Indent"));
  165.     textBox->SetValue(info.indent.right);
  166.     
  167.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Top Indent"));
  168.     textBox->SetValue(info.indent.top);
  169.     
  170.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Bottom Indent"));
  171.     textBox->SetValue(info.indent.bottom);
  172.  
  173.     control = dynamic_cast<TControl*>(this->FindSubPane("Erase on Update"));
  174.     control->SetValue(info.eraseOnUpdate);
  175. }
  176.  
  177.  
  178.  
  179.